<script type="text/javascript">
function validate_form() {
    <?php
        if(count($this->language) > 0) :
            foreach($this->language as $value) :
    ?>
    if($('#tabs-<?php echo $value['locale'] ?>').hasClass('ui-tabs-hide') == false) {
        var name_<?php echo $value['locale'] ?> = $('#name-<?php echo $value['locale'] ?>').val();
        var countError = 0;
        if((name_<?php echo $value['locale'] ?>.length < 1) || (name_<?php echo $value['locale'] ?>.length > 50)) {
            $('#errorName-<?php echo $value['locale'] ?>').html('Tên địa điểm từ 1-50 kí tự');
            return false;
        }
        else {
            $.ajax({ 
               url: "<?php echo $this->url(array('module'=>'admincp','controller'=>'location','action'=>'check'));?>", 
               type: "post",
               data: "id="+null+"&name="+name_<?php echo $value['locale'] ?>,
               cache: false,
               async :false,
               success :function(result) {
                   if (result !='') {
                       $('#errorName-<?php echo $value['locale'] ?>').html(result);
                       countError++;
                   }
                   else {
                	   $('#errorName-<?php echo $value['locale'] ?>').html('');
                   }
               }
            });
            if(countError > 0) {
                return false;
            }
            else {
                return true;
            }
        }
    }
    <?php
            endforeach;
        endif;
    ?>
};
</script>
    <div class="list_category">
        <ul>
            <li><a href="<?php echo $this->baseUrl('admincp/location'); ?>">Quản lý địa điểm</a></li>
        </ul>
    </div>
</div>

<!-- Begin Content -->
<div class="section">
    <div class="heading_section">
        <span>Tạo địa điểm mới</span>
    </div>
    
    <div class="content">
    <form action="" method="post" onsubmit="return validate_form()">
        <div id="tabs">
            <ul>
                <?php
                    if(count($this->language) > 0) :
                        foreach($this->language as $value) :
                ?>
                    <li><a href="#tabs-<?php echo $value['locale']; ?>"><?php echo $value['name']; ?></a></li>
                <?php
                        endforeach;
                    endif;
                ?>
            </ul>
            <table class="table">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('parent','Địa điểm cha'); ?>&nbsp;&nbsp;&nbsp;</td>
                    <td class="td2">
                        <select name="parent" class="selectbox">
                        <option value="0">----------Tất cả----------</option>
                        <?php
                            $location = new Admincp_Model_Location();
                            echo $location->listMenu(0, $this->parent);
                        ?>
                        </select>
                    </td>
                    <td class="td3">&nbsp;</td>
                </tr>
            </table>
            <?php
                if(count($this->language) > 0) :
                    foreach($this->language as $value) :
            ?>
            <div id="tabs-<?php echo $value['locale']; ?>">
                <table class="table">
                    <tr>
                        <td class="td1"><?php echo $this->formLabel('name-'.$value['locale'],'Địa điểm'); ?>&nbsp;<span class="error-msg">*</span></td>
                        <td class="td2"><?php echo $this->formText('name-'.$value['locale'],null,array('class'=>'input')); ?></td>
                        <td class="td3" id="errorName-<?php echo $value['locale']; ?>"></td>
                    </tr>
                </table>
            </div>
            <?php
                    endforeach;
                endif;
            ?>
            <table class="table">
                <tr>
                    <td class="td1">&nbsp;</td>
                    <td class="td2">
                        <?php echo $this->formSubmit('submit','Chấp nhận',array('class'=>'button')); ?>
                        <?php echo $this->formReset('reset','Nhập lại',array('class'=>'button')); ?>
                    </td>
                    <td class="td3"></td>
                </tr>
            </table>
        </div>
    </form>
    </div>
</div>
<!-- End Content -->